package client;

import java.io.File;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.List;

import org.ejs.bean.FileManagerRemote;
import org.ejs.bean.ServerManagerRemote;
import org.ejs.network.ServerAddress;

import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;


public class Client {
	
	File dossier;
	Socket socket;
	ServerSocket serverSocket;
	
	public Client(String folderShared) throws MessagingException{
				
		File dir = new File (folderShared);
		if (dir.exists()){
			dossier = dir;
		}
		else{
			
			dir.mkdirs();
		}
	}
	
	public static void main(String args[]) throws Exception { 
		javax.naming.Context ic = new javax.naming.InitialContext(ClientTools.giveMeJndiProperties()); 
		//FileManagerRemote bean = (FileManagerRemote) ic.lookup("ejb:/ejs/FileManager!org.ejs.bean.FileManagerRemote?stateful");
		ServerManagerRemote bean = (ServerManagerRemote) ic.lookup("ejb:/ejs/ServerManager!org.ejs.bean.ServerManagerRemote");
		//bean.connect(new ServerAddress("127.0.0.1", 14121));
		FileManagerRemote file = bean.connect(new ServerAddress("127.0.0.1", 15274));
		file.add("last1;");
		file.add("last");
		List<String> list = file.list(new ServerAddress("127.0.0.1", 14121));
		for (String string : list) {
			System.out.println(string);
		}
		//appel des fonctions ici
	}
	
}
